package com.jxd.ordering.config;

import com.jxd.ordering.handle.GlobalInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName GlobalInterceptorConfig
 * @Description TODO
 * @Author Ankailong
 * @Date 2022/9/29
 * @Version 1.0
 */
@Configuration
public class GlobalInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private GlobalInterceptor demoInterceptor;

    //配置拦截器的映射
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截除登录，上传的图片外的所有请求
        registry.addInterceptor(demoInterceptor).addPathPatterns("/**").excludePathPatterns("/login").
                excludePathPatterns("/static/upload/**");
    }
}
